
package com.wangshb.upms.core.common;

import java.io.Serializable;

public class GpResponse<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int code = 2000;
    private Boolean result = true;
    private String msg = "";
    private T data;

    public GpResponse() {
    }

    public GpResponse(Boolean result, String msg, int code) {
        this.result = result;
        this.msg = msg;
        this.code = code;
    }

    public GpResponse(Boolean result, String msg) {
        this.result = result;
        this.msg = msg;
    }

    public Boolean getResult() {
        return this.result;
    }

    public void setResult(Boolean result) {
        this.result = result;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> GpResponse<T> success(T data) {
        GpResponse<T> tGpResponse = new GpResponse();
        tGpResponse.setMsg(null);
        tGpResponse.setResult(true);
        tGpResponse.setData(data);
        return tGpResponse;
    }

    public static <T> GpResponse<T> success(String msg, T data) {
        GpResponse<T> tGpResponse = new GpResponse();
        tGpResponse.setMsg(msg);
        tGpResponse.setResult(true);
        tGpResponse.setData(data);
        return tGpResponse;
    }

    public static <T> GpResponse<T> success(String msg, T data, int code) {
        GpResponse<T> tGpResponse = new GpResponse();
        tGpResponse.setMsg(msg);
        tGpResponse.setCode(code);
        tGpResponse.setResult(true);
        tGpResponse.setData(data);
        return tGpResponse;
    }

    public static <T> GpResponse<T> fail(String msg, T data) {
        GpResponse<T> tGpResponse = new GpResponse();
        tGpResponse.setMsg(msg);
        tGpResponse.setResult(false);
        tGpResponse.setData(data);
        return tGpResponse;
    }

    public static <T> GpResponse<T> fail(String msg, T data, int code) {
        GpResponse<T> tGpResponse = new GpResponse();
        tGpResponse.setMsg(msg);
        tGpResponse.setResult(false);
        tGpResponse.setCode(code);
        tGpResponse.setData(data);
        return tGpResponse;
    }

    public void setResult(Boolean result, String msg) {
        this.result = result;
        this.msg = msg;
    }

    public void setResult(Boolean result, String msg, int code) {
        this.result = result;
        this.msg = msg;
        this.code = code;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
